package PRODUCT;

import java.net.InetAddress;
import java.net.UnknownHostException;

import javax.swing.JFrame;
import javax.swing.WindowConstants;

import LOGISTICS.m_materialRequestList;
import TOOLS.SQLtool;

public class test001 {

	public static void main(String[] args) {
		SQLtool sql=new SQLtool();
		String IPaddr="192.168.1.1";
		try {
			InetAddress addr = InetAddress.getLocalHost();
			IPaddr=addr.getHostAddress();
		} catch (UnknownHostException e1) {
			;
		}
		sql.config(IPaddr, "AKS2019", "sa", "123456","test211126006");
		sql.config("192.168.0.39", "AKS2019", "sa", "abcd1234!","test211126006");
		try {
			JFrame j=new JFrame();
			j.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
			j.setVisible(true);
			j.setLocation(-800, 0);
			sql.connect();

			productionCounter co=new productionCounter(sql);
			co.setStationID("CL.EN.1035-H");
			co.start();
			for(int i=0;i<100;i++) {
				test(co,15,25,3000);//40
				test(co,3,6,2000);//9	//49
				test(co,13,13,1500);//26	//75
				test(co,25,5,2500);//30	//105
				test(co,15,5,3100);//20	//125
				test(co,3,6,2200);//9	//134
			}
			
			Thread.sleep(4000);
			co.close();
			j.dispose();
//			System.exit(0);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void test(productionCounter co, int iC, int jC,int time) {
		new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					for(int i=0;i<iC;i++) {
						co.callCounter(true);
						co.callCounter(false);
					}
					Thread.sleep(time);
					for(int i=0;i<jC;i++) {
						co.callCounter(true);
						co.callCounter(false);
					}
				} catch (Exception ee) {
					;
				}
			}

		}).start();
	}

}
